<template>
    <div>
        <el-dialog
            title="添加分类"
            :visible.sync="dialogVisible"
            width="50%"
        >

            <el-form ref="form" :model="form" label-width="80px">
                <el-form-item label="类别名称">
                    <el-input v-model="form.kindName"></el-input>
                </el-form-item>

                <el-form-item label="提问价格">
                    <el-input v-model="form.kindAskPrice" type="number"></el-input>
                </el-form-item>

                <el-form-item label="按钮文字">
                    <el-input v-model="form.kindSolution" type="text"></el-input>
                </el-form-item>

                <el-form-item label="类别标语" >
                    <el-input v-model="form.kindAdvantage1" type="text" style="width:45% !important; margin-right:20px; float:left"></el-input>
                    <el-input v-model="form.kindAdvantage2" type="text" style="width:45% !important;float:left"></el-input>
                </el-form-item>

                <el-form-item label="首页显示" >
                    <el-switch
                    style="float:left;margin-top: 10px; margin-left: 30px; transform: scale(1.3,1.3)"
                    v-model="form.isShowPage"
                    active-color="#13ce66"
                    inactive-color="#ff4949"
                    >
                    </el-switch>
                </el-form-item>

                <el-form-item label="显示问题" >
                    <el-switch
                    style="float:left;margin-top: 10px; margin-left: 30px; transform: scale(1.3,1.3)"
                    v-model="form.isShow"
                    active-color="#13ce66"
                    inactive-color="#ff4949"
                    >
                    </el-switch>
                </el-form-item>

                <el-form-item label="类别图标">
                    <Upload 
                        src=""
                        :model="form"
                        imgName="kindLogoUrl"
                    ></Upload>
                </el-form-item>
                
                <el-form-item>
                    <el-button type="primary" @click="confirm">确定</el-button>
                    <el-button @click="cancel">取消</el-button>
                </el-form-item>

            </el-form>
       


        </el-dialog>
    </div>
</template>

<script>
import Upload from 'template/Upload'
export default {
    name: 'Dialog',
    components: {
        Upload
    },
    data () {
        return {
            dialogVisible: false,
            form: {
                kindName: '',
                kindLogoUrl: '',
                kindAskPrice: '',
                kindSolution: '',
                kindAdvantage1: '',
                kindAdvantage2: '',
                isShowPage: true,
                isShow: true
            }
        }
    },
    methods: {
        show () {
            this.dialogVisible = true;
        },
        getUploadRes (e) {
            this.form.kindLogoUrl = e;
        },
        checkForm () {
            var form = this.form;
            for (var i in form) {
                if (form[i] === undefined || form[i] === '') {
                    return false;
                }
                else {

                }
            }
            return true;
        },
        confirm () {
            
            if (this.checkForm()) {
                this.dialogVisible = false;
                this.$emit('submit', this.form);
            }
            else {
                this.$message("请确认填写完整");
            }
        },
        cancel () {
            this.dialogVisible = false;
        }
    }
}
</script>

<style lang="stylus" scoped>
    
</style>


